package com.demo;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

class User{
	private String name;
    private int age;

    public User(String name,int age){
        this.age = age;
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
    	return true;
    }
    @Override
    public int hashCode() {
    	return 1;
    }
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

	@Override
	public String toString() {
		return "User [name=" + name + ", age=" + age + "]";
	}
    
}
public class Demo1 {

	public static void main(String[] args) throws IOException {
		
		String str = "我是个测试";
        //1获取字节数组
        byte[] bytes = str.getBytes() ;
        
        System.out.println("压缩前的长度：" + bytes.length); 
        //2
        ByteArrayOutputStream baos = new ByteArrayOutputStream() ; 
        GZIPOutputStream  gzip = new GZIPOutputStream(baos) ;
        
        gzip.write(bytes) ; 
        gzip.close() ;
        //3
        bytes = baos.toByteArray() ;
        System.out.println("压缩后的长度：" + bytes.length);
		/*User user1 = new User("a",1);
		User user2 = new User("b",2);
		User user3 = new User("c",3);
		User user4 = new User("d",4);
        Map<User,Integer> map = new HashMap<>();
        map.put(user1, 11);
        map.put(user2, 22);
        map.put(user3, 33);
        map.put(user4, 44);
        System.out.println(map.size());
        for(Entry<User, Integer> entry:map.entrySet()){
        	System.out.println(entry.getKey() +"--->"+ entry.getValue());
        }
        
        Map<String,Integer> m = new HashMap<>();
        m.put("aa",1);
        m.put("aa",2);
        m.put("aa",3);
        System.out.println(m);*/
	}
	

}
